package com.yupi.project.bizmq;

import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class MyMessageConsumer {
    @SneakyThrows
    @RabbitListener(queues = "code_queue",ackMode = "MANUAL")
    public void receive(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG)long deliveryTag) {
        log.info("receive message: " + msg);
        channel.basicAck(deliveryTag,false);
    }
}
